import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:verse_systems/res/colors.dart';
import 'package:verse_systems/utils/image_utils.dart';
import 'package:verse_systems/widgets/back_button.dart';

//CustomCourseAppbar
class CustomCourseAppbar extends StatelessWidget
    implements PreferredSizeWidget {
  final String title;
  final String sbutitle;
  final String text;
  final double preferred;
  final String background;
  final double bottom;
  const CustomCourseAppbar(
      {super.key,
      this.title = "",
      this.sbutitle = "",
      this.text = "",
      this.preferred = 150,
      this.background = "score_background",
      this.bottom = 30});

  @override
  Widget build(BuildContext context) {
    return AppBar(
        backgroundColor: Colours.app_main_color,
        title: Text(
          title,
          style: TextStyle(
              fontSize: 18.sp,
              fontWeight: FontWeight.normal,
              color: Colours.app_main_color),
        ),
        elevation: 0,
        centerTitle: true,
        leading: IosBackButton(
          color: Colours.app_main_color,
          size: 16.w,
        ),
        flexibleSpace: FlexibleSpaceBar(
          centerTitle: true,
          titlePadding: EdgeInsets.only(bottom: bottom.w),
          title: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            mainAxisSize: MainAxisSize.min,
            children: [
              Text(
                sbutitle,
                style: TextStyle(
                    fontSize: 32.sp,
                    color: Colours.app_main_color,
                    fontWeight: FontWeight.w600),
              ),
              SizedBox(height: 5.w),
              Text(
                text,
                style: TextStyle(
                  fontSize: 12.sp,
                  color: Colours.app_main_color,
                ),
              ),
            ],
          ),
          background: Container(
            decoration: BoxDecoration(
              image: DecorationImage(
                image: ExactAssetImage(
                  ImageUtils.getFromAssetImage(background),
                ),
                fit: BoxFit.fill,
              ),
            ),
          ),
        ));
  }

  @override
  Size get preferredSize => Size.fromHeight(preferred.w);
}
